package com.cy.pj.common.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class ServletUtil {
    /**
     * 获取请求对象
     */
    public static HttpServletRequest getReuquest(){
        return getServletRequestAttributes().getRequest();
    }

    /**
     * 通过RequestContexHolder类型获取请求属性
     */
    private static ServletRequestAttributes getServletRequestAttributes() {
        return (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
    }
}
